%!PS-Adobe-3.0 EPSF-3.0
%%Title:                     fig-rectangle
%%BoundingBox:     -16   15   315   207
%%EndComments

% these procedures have been posted in comp.lang.postscript
% by Bill Lee, bill@leeweyr.sccsi.com, on Apr 19 1995
% subject: arc with arrow head
% changes by Cristian Barbarosie in 2018 cristian.barbarosie@gmail.com


%* _____________________________ Arrows ____________________________________ 

%* Procedure to draw the path for an arrow head. Note: the arrowhead will be 
%* added to the current path. The arrowhead will also be drawn and filled. 
%* 
%* Usage: Linewidth deltaX deltaY ArrowHead 
%* 
%* where: LineWidth is the width in points of the arrow head lines 
%* 
%* deltaX and deltaY define the direction that the arrow points 
%* 
%* Note: If Linewidth is zero, a value of 1 will be substituted 
%*
/rArrowHead { 
exch atan matrix currentmatrix exch rotate exch 
dup 0 eq 
{ pop 1 } if 
dup scale 
-7 2 rlineto 
1 -2 rlineto 
-1 -2 rlineto 
% closepath
% with closepath we get a sharp arrow
7 2 rlineto
% with rlineto we get a pointless arrow (not ugly)
currentpoint 
gsave
newpath moveto 
-7 2 rlineto 
1 -2 rlineto 
-1 -2 rlineto 
closepath 
fill 
grestore 
setmatrix 
} def 

%* Procedure to draw the path for an arrow head. Note: the arrowhead will be 
%* added to the current path. The arrowhead will also be drawn and filled. 
%* 
%* Usage: Linewidth PreviousX PreviousY ArrowHead 
%* 
%* where: LineWidth is the width in points of the arrow head lines 
%* 
%* PreviousX and PreviousY along with the currentpoint 
%* define the direction that the arrow points 
%* 
%* Note: If Linewidth is zero, a value of 1 will be substituted 
%*
/ArrowHead { 
currentpoint 
4 2 roll exch 4 -1 roll exch 
sub 3 1 roll sub
rArrowHead
} def 

%* _____________________________ RLineto^ ____________________________________ 
%* Procedure to add a relative line to the current path and then add the 
%* path for an arrow on its end. 
%* 
%* Usage: x y RLineto^ 
%* 
%* where: x and y are the offsets from the current point 
%* 
/RLineto^ { 
currentlinewidth currentpoint 5 3 roll 
rlineto 
ArrowHead 
} def 

%* _____________________________ Lineto^ ____________________________________ 
%* Procedure to add a line to the current path and then add the 
%* path for an arrow on its end. 
%* 
%* Usage: x y Lineto^ 
%* 
%* where: x and y are the new points for the path 
%* 
/Lineto^ { 
currentlinewidth currentpoint 5 3 roll 
lineto 
ArrowHead 
} def 

%* _____________________________ Arc^ ____________________________________ 
%* Procedure to add an arc to the current path and then add the 
%* path for arrow on its end. 
%* 
%* Usage: x y r ang1 ang2 Arc^ 
%* 
%* where: x, y, ang1, ang2, and r are the normal parameters 
%* for drawing an arc. 
%* 
/Arc^ { 
5 copy arc 
exch pop 2 sub 
dup cos 2 index mul 4 index add 
exch sin 2 index mul 3 index add 
currentlinewidth 3 1 roll 
ArrowHead pop pop pop 
} def 

%* _____________________________ Arcn^ ____________________________________ 
%* Procedure to add an arc to the current path and then add the 
%* path for arrow on its end. 
%* 
%* Usage: x y r ang1 ang2 Arcn^ 
%* 
%* where: x, y, ang1, ang2, and r are the normal parameters 
%* for drawing an arcn. 
%* 
/Arcn^ { 
5 copy arcn 
exch pop 2 add 
dup cos 2 index mul 4 index add 
exch sin 2 index mul 3 index add 
currentlinewidth 3 1 roll 
ArrowHead pop pop pop 
} def 

% from xfig :
/DrawEllipse {
	/endangle exch def
	/startangle exch def
	/yrad exch def
	/xrad exch def
	/y exch def
	/x exch def
	/savematrix matrix currentmatrix def
	x y translate xrad yrad scale 0 0 1 startangle endangle arc
	closepath
	savematrix setmatrix
} def


1 setlinecap

0.8 setgray
30 50 moveto 270 50 lineto stroke
30 70 moveto 270 70 lineto stroke
30 110 moveto 270 110 lineto stroke
30 130 moveto 270 130 lineto stroke
30 150 moveto 270 150 lineto stroke
30 170 moveto 270 170 lineto stroke

60 190 moveto 60 30 lineto stroke
90 190 moveto 90 30 lineto stroke
120 190 moveto 120 30 lineto stroke
180 190 moveto 180 30 lineto stroke
210 190 moveto 210 30 lineto stroke
240 190 moveto 240 30 lineto stroke


0.65 setgray 2 setlinewidth
30 90 moveto 270 90 lineto stroke
32 90 moveto 1.2 -1 0 rArrowHead
268 90 moveto 1.2 1 0 rArrowHead
150 30 moveto 150 190 lineto stroke
150 32 moveto 1.2 0 -10 rArrowHead
150 188 moveto 1.2 0 10 rArrowHead stroke
150 90 moveto 150 90 3 0 360 arc fill

1 0.5 0 setrgbcolor 1.5 setlinewidth
60 90 moveto 60 30 lineto stroke
90 90 moveto 90 30 lineto stroke
120 90 moveto 120 30 lineto stroke
150 70 moveto 150 30 lineto stroke
180 70 moveto 180 30 lineto stroke
210 70 moveto 210 30 lineto stroke
240 70 moveto 240 30 lineto stroke

30 50 moveto 270 50 lineto stroke
30 70 moveto 270 70 lineto stroke
30 90 moveto 120 90 lineto stroke

2 setlinewidth
30 30 moveto 30 190 lineto 270 190 lineto 270 30 lineto closepath stroke

/Courier findfont 15 scalefont setfont
-12 120 moveto (west) show
277 120 moveto (east) show
140 195 moveto (north) show
100 18 moveto (south) show
110 59 moveto (A) show
152 59 moveto (B) show
152 93 moveto (C) show
110 93 moveto (D) show

showpage
%%Trailer
%EOF
